<!DOCTYPE html>
<html>
		<head>
			<meta charset="UTF-8">
			<meta charset="utf-8">
			<meta http-equiv="X-UA-Compatible" content="IE=edge">
			<meta name="viewport" content="width=device-width, initial-scale=1">
			<title>修改员工信息</title>
			<link rel="shortcut icon" href="assets/ico/favicon.ico" type="image/x-icon" />
			<link href="assets/css/bootstrap.min.css" rel="stylesheet">
			<link href="assets/css/jquery.mmenu.css" rel="stylesheet">
			<link href="assets/css/font-awesome.min.css" rel="stylesheet">
			<link href="assets/plugins/jquery-ui/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
			<link href="assets/plugins/chosen/css/chosen.css" rel="stylesheet">
			<link href="assets/css/style.min.css" rel="stylesheet">
			<link href="assets/css/add-ons.min.css" rel="stylesheet">
		</head>
	<body>
		<div class="row">
			<div class="col-md-6">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h2><i class="fa fa-indent red"></i><strong>修改员工信息</strong></h2>
					</div>
					<div class="panel-body">
						<form action="/updateemplyee" method="post" >

							<div class="form-group">
								<label class="col-md-3 control-label" for="text-input">编号：</label>
								<div class="col-md-9">
									<input type="text" name="employeeid" class="form-control" readonly >
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label" for="text-input">姓名：</label>
								<div class="col-md-9">
									<input type="text"   name="employeename" class="form-control"  >
								</div>
							</div>
							
							<div class="form-group">
								<label class="col-md-3 control-label" >身份证号：</label>
								<div class="col-md-9">
									<input type="text" id="employeeid"  name="employeeidnumber" class="form-control">
								</div>
							</div>
							
							<div class="form-group">
								<label class="col-md-3 control-label" for="text-input">联系电话：</label>
								<div class="col-md-9">
									<input type="text" id="text-input" name="employeephonenumber" class="form-control">
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label">状态</label>
								<div class="col-md-9">
									<div class="radio">
										<label for="radio1">
											<input type="radio" id="radio1" name="status" value="0" checked="checked"> 未离职
										</label>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label" >部门名称：</label>
								<div class="col-md-9">
									<!--<select id="select" name="fkdepartmentinfo.departmentid" class="form-control" size="1">-->
										<!--<option  value="1">财务部</option>-->
										<!--<option value="2">材料供应部</option>-->
										<!--<option value="3">接待部</option>-->
										<!--<option value="4">维修部</option>-->
									<!--</select>-->
									<input type="text" id="departmentid" name="fkdepartmentinfo.departmentid" class="form-control">
								</div>
							</div>
							<div class="form-group">
				                    <label class="col-md-3 control-label">性别：</label>
				                    <div class="col-md-8">
				                        <label class="radio-inline" for="inline-radio1">
				                        	<input type="radio" id="inline-radio1" name="employeesex" value="男"> 男
				                        </label>
				                        <label class="radio-inline" for="inline-radio2">
				                        	<input type="radio" id="inline-radio2" name="employeesex" value="女"> 女
				                        </label>
				                    </div>
				             </div>
							
							
							<div >
								<button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 修改</button>
								<button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i> 重置</button>
								<button type="button" class="btn btn-sm btn-danger"  onclick="javascript:history.back(-1);"><i class="fa fa-ban"></i> 返回</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
		<script src="assets/js/jquery-1.4.1.js"></script>
		<script type="text/javascript">
			//拿到上一个页面跳转来的值和路径
			// alert(document.location.href);
			//拿到页面跳转到页面的值
            var lcahref = location.search;
            // alert(location.search)
            lcahref = lcahref.substring(12);
			$(function(){
                $.ajax({
					url:"/queryID",
					data:{"employeeid":lcahref},
					type:"post",
                    success:function (employeeInfo){
					    console.log(employeeInfo)
						$("input[name=employeeid]").val(employeeInfo.employeeid);
					    $("input[name=employeename]").val(employeeInfo.employeename);
					    $("input[name=employeeidnumber]").val(employeeInfo.employeeidnumber);
					    $("input[name=employeephonenumber]").val(employeeInfo.employeephonenumber);
					    var sex=employeeInfo.employeesex
					    if(sex=="男"){
                            $("input[id=inline-radio1]").attr("checked","checked");
						}
						if(sex=="女"){
                            $("input[id=inline-radio2]").attr("checked","checked");
						}
                        $("input[name=employeephonenumber]").val(employeeInfo.employeephonenumber);
                        var name=""
                        if(employeeInfo.fkdepartmentinfo.departmentid==1){
                            name="财务部";
						}else if(employeeInfo.fkdepartmentinfo.departmentid==2){
                            name="材料供应部";
						}else if(employeeInfo.fkdepartmentinfo.departmentid==3){
                            name="接待部";
                        }else {
                            name="维修部";
						}
                        $("#departmentid").val(name);
                        // var  idval= $("select[name=fkDepartmentid]").val();
                        // if(idval==employeeInfo.fkdepartmentinfo.departmentid){
                         //    $("select[name=fkDepartmentid]:eq(aa-1)").attr("selected","selected");
						// }

                        // var  depar=employeeInfo.fkdepartmentinfo.departmentid;
                        // if(depar==1){
                        //     $("#select:eq(0)").attr("selected","selected");
                        // }
                        // if(depar==2){
                        //     $("#select:eq(1)").attr("selected","selected");
                        // }
                        // if(depar==3){
                        //     $("#select:eq(2)").attr("selected","selected");
                        // }
                        // if(depar==4){
                        //     $("#select:eq(3)").attr("selected","selected");
                        // }

					}
				});
                $("input[name=employeename]").bind("blur",function(){
                    //清空
                    $(this).nextAll("span").remove();
                    var Emali=$(this).val();
                    if(Emali==null){
                        //如果不通过就给出提示
                        $("input[name=employeename]").after("<span>姓名不能为空</span>");
                    }
                });

                $("input[name=employeeidnumber]").bind("blur",function(){
                    //清空
                    $(this).nextAll("span").remove();
                    var Emali=$(this).val();
                    if(Emali==null){
                        //如果不通过就给出提示
                        $("input[name=employeeidnumber]").after("<span>联系电话不能为空</span>");
                    }
                });
                
                  $("input[name=fkdepartmentid]").bind("blur",function(){
                    //清空
                    $(this).nextAll("span").remove();
                    var Emali=$(this).val();
                    if(Emali==null){
                        //如果不通过就给出提示
                        $("input[name=fkdepartmentid]").after("<span>部门名称不能为空</span>");
                    }
                });

                //绑定提交事件
                $("form").bind("submit",function(){
                    //让form表单默认执行blur()方法
                    $("form").trigger("blur");
                    //如果span标签有值就表示有错误信息不能提交表单
                    if($("span").length>0){
                        return false;
                    }
                   
                });
            });
		</script>
</html>
